import java.util.Random;
import java.util.Scanner;

public class Main {

    // 函数用于计算两点之间的距离
    private static double distance(double x1, double y1, double x2, double y2) {
        return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
    }

    // 函数用于计算三角形的面积（海伦公式）
    private static double triangleArea(double a, double b, double c) {
        double s = (a + b + c) / 2;
        return Math.sqrt(s * (s - a) * (s - b) * (s - c));
    }

    // 函数用于计算三角形的周长
    private static double trianglePerimeter(double a, double b, double c) {
        return a + b + c;
    }

    // 函数用于生成圆上的随机点
    private static double[] getRandomPointOnCircle(Random rand, double radius) {
        double angle = rand.nextDouble() * 2 * Math.PI; // 随机角度
        double x = radius * Math.cos(angle);
        double y = radius * Math.sin(angle);
        return new double[]{x, y};
    }

    public static void main(String[] args) {
        Random rand = new Random();
        Scanner scanner = new Scanner(System.in);

        // 定义圆心和半径
        double centerX = 0;
        double centerY = 0;
        double radius = 50;

        // 生成三个随机点
        double[] point1 = getRandomPointOnCircle(rand, radius);
        double[] point2 = getRandomPointOnCircle(rand, radius);
        double[] point3 = getRandomPointOnCircle(rand, radius);

        // 计算三边长度
        double a = distance(point1[0], point1[1], point2[0], point2[1]);
        double b = distance(point2[0], point2[1], point3[0], point3[1]);
        double c = distance(point3[0], point3[1], point1[0], point1[1]);

        // 计算周长和面积
        double perimeter = trianglePerimeter(a, b, c);
        double area = triangleArea(a, b, c);

        // 显示结果
        System.out.println("三个随机点的坐标分别为：");
        System.out.println("点1: (" + point1[0] + ", " + point1[1] + ")");
        System.out.println("点2: (" + point2[0] + ", " + point2[1] + ")");
        System.out.println("点3: (" + point3[0] + ", " + point3[1] + ")");

        System.out.println("三角形的周长为: " + perimeter + "cm");
        System.out.println("三角形的面积为: " + area + "cm^2");
    }
}